<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>仓库子表信息</title>
    <script src="/js/global.js"></script>
    <link rel="stylesheet" href="/css/font.css" type="text/css"/>
    <link rel="stylesheet" href="/css/layui.css" type="text/css"/>
    <link rel="stylesheet" href="/css/xadmin.css" type="text/css"/>
    <script type="text/javascript" src="/js/layui.js" ></script>
    <script type="text/javascript" src="/js/xadmin.js" ></script>
    <script type="text/javascript" src="/js/jquery-3.5.1.min.js" ></script>
</head>
<body>
<!-- 条件查询 -->
<div class="layui-form-item" style="margin-top: 20px;" onsubmit="false">
    <div class="layui-form-item">

        <input type="text" name="warehouseid" id="warehouseid" placeholder="ID" style="display: none;" class="layui-input">

        <label class="layui-form-label">名称</label>
        <div class="layui-input-inline" style="width: 200px;">
            <input type="text" name="title" id="title" placeholder="名称" class="layui-input">
        </div>

        <label class="layui-form-label">采购者</label>
        <div class="layui-input-inline" style="width: 200px;">
            <input type="text" name="username" id="username" placeholder="采购者" class="layui-input">
        </div>

        <button class="layui-btn" id="search" data-type="reload">查询</button>

    </div>
</div>

<!-- 表格 -->
<table id="test" class="layui-hide" lay-filter="test"></table>

<script>
    layui.use(['layer', 'table', 'form', 'transfer', 'util', 'laydate'], function() {
        var table = layui.table;
        var $ = layui.jquery;
        var form = layui.form;
        var transfer = layui.transfer;
        var util = layui.util;
        var laydate = layui.laydate;

        initData();

        function initData() {
            //初始化表格数据
            table.render({
                elem: '#test',
                url: '../warehouseinfo/selectAll',
                method: "get",
                where: {
                    warehouseid: $("#warehouseid").val(),
                    title: $("#title").val(),
                    username: $("#username").val()
                },
                title: '仓库子表信息',
                page : true,
                id: 'testReload',
                //修改响应数据
                parseData: function(res) {
                    return {
                        "code": 0, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.count, //解析数据长度
                        "data": res.data.data //解析数据列表
                    };
                },
                cols: [
                    [{
                        field: 'id',
                        title: 'ID',
                        align: 'center'
                    },
                        {
                            field: 'title',
                            title: '商品名称',
                            align: 'center'
                        },     {
                        field: 'img',
                        title: '图片',
                        align: 'center',
                        templet: function(d){
                            return '<img src="'+d.img+'" width="200px" height="200px">';
                        }
                    },
                        {
                            field: 'price',
                            title: '价格',
                            align: 'center'
                        },
                        {
                            field: 'adminname',
                            title: '采购者',
                            align: 'center'
                        },
                        {
                            field: 'stock',
                            title: '库存',
                            align: 'center'
                        }
                    ]
                ]
            });
        }



        //模糊查询
        $('#search').on('click', function() {
            initData();
        });


    });
</script>
</body>
</html>
